home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / ixemul / sdk / man / cat4 / termios.0 < prev    next >
Encoding:
Text File  |  1998-06-15  |  39.9 KB  |  707 lines

  1.  
  2. TERMIOS(4)                 UNIX Programmer's Manual                 TERMIOS(4)
  3.  
  4. NNAAMMEE
  5.      tteerrmmiiooss - general terminal line discipline
  6.  
  7. SSYYNNOOPPSSIISS
  8.      ##iinncclluuddee <<tteerrmmiiooss..hh>>
  9.  
  10. DDEESSCCRRIIPPTTIIOONN
  11.      This describes a general terminal line discipline that is supported on
  12.      tty asynchronous communication ports.
  13.  
  14.    OOppeenniinngg aa TTeerrmmiinnaall DDeevviiccee FFiillee
  15.      When a terminal file is opened, it normally causes the process to wait
  16.      until a connection is established.  For most hardware, the presence of a
  17.      connection is indicated by the assertion of the hardware CARRIER line. If
  18.      the termios structure associated with the terminal file has the CLOCAL
  19.      flag set in the cflag, or if the O_NONBLOCK flag is set in the open(2)
  20.      call, then the open will succeed even without a connection being present.
  21.      In practice, applications seldom open these files; they are opened by
  22.      special programs, such as getty(2) or rlogind(2),  and become an applica-
  23.      tion's standard input, output, and error files.
  24.  
  25.    JJoobb CCoonnttrrooll iinn aa NNuuttsshheellll
  26.      Every process is associated with a particular process group and session.
  27.      The grouping is hierarchical: every member of a particular process group
  28.      is a member of the same session.  This structuring is used in managing
  29.      groups of related processes for purposes of _j_o_b _c_o_n_t_r_o_l; that is, the
  30.      ability from the keyboard (or from program control) to simultaneously
  31.      stop or restart a complex command (a command composed of one or more re-
  32.      lated processes).  The grouping into process groups allows delivering of
  33.      signals that stop or start the group as a whole, along with arbitrating
  34.      which process group has access to the single controlling terminal.  The
  35.      grouping at a higher layer into sessions is to restrict the job control
  36.      related signals and system calls to within processes resulting from a
  37.      particular instance of a "login".  Typically, a session is created when a
  38.      user logs in, and the login terminal is setup to be the controlling ter-
  39.      minal; all processes spawned from that login shell are in the same ses-
  40.      sion, and inherit the controlling terminal.  A job control shell operat-
  41.      ing interactively (that is, reading commands from a terminal) normally
  42.      groups related processes together by placing them into the same process
  43.      group.  A set of processes in the same process group is collectively re-
  44.      ferred to as a "job". When the foreground process group of the terminal
  45.      is the same as the process group of a particular job, that job is said to
  46.      be in the "foreground".  When the process group of the terminal is dif-
  47.      ferent than the process group of a job (but is still the controlling ter-
  48.      minal), that job is said to be in the "background".  Normally the shell
  49.      reads a command and starts the job that implements that command.  If the
  50.      command is to be started in the foreground (typical), it sets the process
  51.      group of the terminal to the process group of the started job, waits for
  52.      the job to complete, and then sets the process group of the terminal back
  53.      to its own process group (it puts itself into the foreground).  If the
  54.      job is to be started in the background (as denoted by the shell operator
  55.      "&"), it never changes the process group of the terminal and doesn't wait
  56.      for the job to complete (that is, it immediately attempts to read the
  57.      next command).  If the job is started in the foreground, the user may
  58.      type a key (usually `^Z') which generates the terminal stop signal
  59.      (SIGTSTP) and has the affect of stopping the entire job.  The shell will
  60.      notice that the job stopped, and will resume running after placing itself
  61.      in the foreground.  The shell also has commands for placing stopped jobs
  62.      in the background, and for placing stopped or background jobs into the
  63.      foreground.
  64.  
  65.  
  66.    OOrrpphhaanneedd PPrroocceessss GGrroouuppss
  67.      An orphaned process group is a process group that has no process whose
  68.      parent is in a different process group, yet is in the same session.  Con-
  69.      ceptually it means a process group that doesn't have a parent that could
  70.      do anything if it were to be stopped.  For example, the initial login
  71.      shell is typically in an orphaned process group.  Orphaned process groups
  72.      are immune to keyboard generated stop signals and job control signals re-
  73.      sulting from reads or writes to the controlling terminal.
  74.  
  75.    TThhee CCoonnttrroolllliinngg TTeerrmmiinnaall
  76.      A terminal may belong to a process as its controlling terminal.  Each
  77.      process of a session that has a controlling terminal has the same con-
  78.      trolling terminal.  A terminal may be the controlling terminal for at
  79.      most one session.  The controlling terminal for a session is allocated by
  80.      the session leader by issuing the TIOCSCTTY ioctl.  A controlling termi-
  81.      nal is never acquired by merely opening a terminal device file.  When a
  82.      controlling terminal becomes associated with a session, its foreground
  83.      process group is set to the process group of the session leader.
  84.  
  85.      The controlling terminal is inherited by a child process during a fork(2)
  86.      function call.  A process relinquishes its controlling terminal when it
  87.      creates a new session with the setsid(2) function; other processes re-
  88.      maining in the old session that had this terminal as their controlling
  89.      terminal continue to have it.  A process does not relinquish its control-
  90.      ling terminal simply by closing all of its file descriptors associated
  91.      with the controlling terminal if other processes continue to have it
  92.      open.
  93.  
  94.      When a controlling process terminates, the controlling terminal is disas-
  95.      sociated from the current session, allowing it to be acquired by a new
  96.      session leader.  Subsequent access to the terminal by other processes in
  97.      the earlier session will be denied, with attempts to access the terminal
  98.      treated as if modem disconnect had been sensed.
  99.  
  100.    TTeerrmmiinnaall AAcccceessss CCoonnttrrooll
  101.      If a process is in the foreground process group of its controlling termi-
  102.      nal, read operations are allowed.  Any attempts by a process in a back-
  103.      ground process group to read from its controlling terminal causes a
  104.      SIGTTIN signal to be sent to the process's group unless one of the fol-
  105.      lowing special cases apply:  If the reading process is ignoring or block-
  106.      ing the SIGTTIN signal, or if the process group of the process is or-
  107.      phaned, the read(2) returns -1 with _e_r_r_n_o _s_e_t _t_o EIO and no signal is
  108.      sent.  The default action of the SIGTTIN signal is to stop the process to
  109.      which it is sent.
  110.  
  111.      If a process is in the foreground process group of its controlling termi-
  112.      nal, write operations are allowed.  Attempts by a process in a background
  113.      process group to write to its controlling terminal will cause the process
  114.      group to be sent a SIGTTOU signal unless one of the following special
  115.      cases apply:  If TOSTOP is not set, or if TOSTOP is set and the process
  116.      is ignoring or blocking the SIGTTOU signal, the process is allowed to
  117.      write to the terminal and the SIGTTOU signal is not sent.  If TOSTOP is
  118.      set, and the process group of the writing process is orphaned, and the
  119.      writing process is not ignoring or blocking SIGTTOU, the write returns -1
  120.      with errno set to EIO and no signal is sent.
  121.  
  122.      Certain calls that set terminal parameters are treated in the same fash-
  123.      ion as write, except that TOSTOP is ignored; that is, the effect is iden-
  124.      tical to that of terminal writes when TOSTOP is set.
  125.  
  126.    IInnppuutt PPrroocceessssiinngg aanndd RReeaaddiinngg DDaattaa
  127.      A terminal device associated with a terminal device file may operate in
  128.      full-duplex mode, so that data may arrive even while output is occurring.
  129.      Each terminal device file has associated with it an input queue, into
  130.      which incoming data is stored by the system before being read by a pro-
  131.      cess.  The system imposes a limit, {MAX_INPUT}, on the number of bytes
  132.      that may be stored in the input queue.  The behavior of the system when
  133.      this limit is exceeded depends on the setting of the IMAXBEL flag in the
  134.      termios _c___i_f_l_a_g. If this flag is set, the terminal is sent an ASCII BEL
  135.      character each time a character is received while the input queue is
  136.      full.  Otherwise, the input queue is flushed upon receiving the charac-
  137.      ter.
  138.  
  139.      Two general kinds of input processing are available, determined by
  140.      whether the terminal device file is in canonical mode or noncanonical
  141.      mode. Additionally, input characters are processed according to the
  142.      _c___i_f_l_a_g and _c___l_f_l_a_g fields.  Such processing can include echoing, which
  143.      in general means transmitting input characters immediately back to the
  144.      terminal when they are received from the terminal.  This is useful for
  145.      terminals that can operate in full-duplex mode.
  146.  
  147.      The manner in which data is provided to a process reading from a terminal
  148.      device file is dependent on whether the terminal device file is in canon-
  149.      ical or noncanonical mode.
  150.  
  151.      Another dependency is whether the O_NONBLOCK flag is set by open() or
  152.      fcntl().  If the O_NONBLOCK flag is clear, then the read request is
  153.      blocked until data is available or a signal has been received.  If the
  154.      O_NONBLOCK flag is set, then the read request is completed, without
  155.      blocking, in one of three ways:
  156.  
  157.            1.   If there is enough data available to satisfy the entire re-
  158.                 quest, and the read completes successfully the number of bytes
  159.                 read is returned.
  160.  
  161.            2.   If there is not enough data available to satisfy the entire
  162.                 request, and the read completes successfully, having read as
  163.                 much data as possible, the number of bytes read is returned.
  164.  
  165.            3.   If there is no data available, the read returns -1, with errno
  166.                 set to EAGAIN.
  167.  
  168.      When data is available depends on whether the input processing mode is
  169.      canonical or noncanonical.
  170.  
  171.    CCaannoonniiccaall MMooddee IInnppuutt PPrroocceessssiinngg
  172.      In canonical mode input processing, terminal input is processed in units
  173.      of lines.  A line is delimited by a newline `\n' character, an end-of-
  174.      file (EOF) character, or an end-of-line (EOL) character.  See the _S_p_e_c_i_a_l
  175.      _C_h_a_r_a_c_t_e_r_s section for more information on EOF and EOL. This means that a
  176.      read request will not return until an entire line has been typed, or a
  177.      signal has been received.  Also, no matter how many bytes are requested
  178.      in the read call, at most one line is returned.  It is not, however, nec-
  179.      essary to read a whole line at once; any number of bytes, even one, may
  180.      be requested in a read without losing information.
  181.  
  182.      {MAX_CANON} is a limit on the number of bytes in a line.  The behavior of
  183.      the system when this limit is exceeded is the same as when the input
  184.      queue limit {MAX_INPUT}, is exceeded.
  185.  
  186.      Erase and kill processing occur when either of two special characters,
  187.      the ERASE and KILL characters (see the _S_p_e_c_i_a_l _C_h_a_r_a_c_t_e_r_s _s_e_c_t_i_o_n), is
  188.      received.  This processing affects data in the input queue that has not
  189.      yet been delimited by a newline NL, EOF, or EOL character.  This un-de-
  190.      limited data makes up the current line.  The ERASE character deletes the
  191.      last character in the current line, if there is any.  The KILL character
  192.      deletes all data in the current line, if there is any.  The ERASE and
  193.      KILL characters have no effect if there is no data in the current line.
  194.      The ERASE and KILL characters themselves are not placed in the input
  195.      queue.
  196.  
  197.  
  198.    NNoonnccaannoonniiccaall MMooddee IInnppuutt PPrroocceessssiinngg
  199.      In noncanonical mode input processing, input bytes are not assembled into
  200.      lines, and erase and kill processing does not occur.  The values of the
  201.      MIN and TIME members of the _c___c_c array are used to determine how to pro-
  202.      cess the bytes received.
  203.  
  204.      MIN represents the minimum number of bytes that should be received when
  205.      the read function successfully returns.  TIME is a timer of 0.1 second
  206.      granularity that is used to time out bursty and short term data transmis-
  207.      sions.  If MIN is greater than { MAX_INPUT}, the response to the request
  208.      is undefined.  The four possible values for MIN and TIME and their inter-
  209.      actions are described below.
  210.  
  211.    CCaassee AA:: MMIINN >> 00,, TTIIMMEE >> 00
  212.      In this case TIME serves as an inter-byte timer and is activated after
  213.      the first byte is received.  Since it is an inter-byte timer, it is reset
  214.      after a byte is received.  The interaction between MIN and TIME is as
  215.      follows:  as soon as one byte is received, the inter-byte timer is start-
  216.      ed.  If MIN bytes are received before the inter-byte timer expires (re-
  217.      member that the timer is reset upon receipt of each byte), the read is
  218.      satisfied.  If the timer expires before MIN bytes are received, the char-
  219.      acters received to that point are returned to the user.  Note that if
  220.      TIME expires at least one byte is returned because the timer would not
  221.      have been enabled unless a byte was received.  In this case (MIN > 0,
  222.      TIME > 0) the read blocks until the MIN and TIME mechanisms are activated
  223.      by the receipt of the first byte, or a signal is received.  If data is in
  224.      the buffer at the time of the read(), the result is as if data had been
  225.      received immediately after the read().
  226.  
  227.    CCaassee BB:: MMIINN >> 00,, TTIIMMEE == 00
  228.      In this case, since the value of TIME is zero, the timer plays no role
  229.      and only MIN is significant.  A pending read is not satisfied until MIN
  230.      bytes are received (i.e., the pending read blocks until MIN bytes are re-
  231.      ceived), or a signal is received.  A program that uses this case to read
  232.      record-based terminal I/O may block indefinitely in the read operation.
  233.  
  234.    CCaassee CC:: MMIINN == 00,, TTIIMMEE >> 00
  235.      In this case, since MIN = 0, TIME no longer represents an inter-byte
  236.      timer.  It now serves as a read timer that is activated as soon as the
  237.      read function is processed.  A read is satisfied as soon as a single byte
  238.      is received or the read timer expires.  Note that in this case if the
  239.      timer expires, no bytes are returned.  If the timer does not expire, the
  240.      only way the read can be satisfied is if a byte is received.  In this
  241.      case the read will not block indefinitely waiting for a byte; if no byte
  242.      is received within TIME*0.1 seconds after the read is initiated, the read
  243.      returns a value of zero, having read no data.  If data is in the buffer
  244.      at the time of the read, the timer is started as if data had been re-
  245.      ceived immediately after the read.
  246.  
  247.    CCaassee DD:: MMIINN == 00,, TTIIMMEE == 00
  248.      The minimum of either the number of bytes requested or the number of
  249.      bytes currently available is returned without waiting for more bytes to
  250.      be input.  If no characters are available, read returns a value of zero,
  251.      having read no data.
  252.  
  253.    WWrriittiinngg DDaattaa aanndd OOuuttppuutt PPrroocceessssiinngg
  254.      When a process writes one or more bytes to a terminal device file, they
  255.      are processed according to the _c___o_f_l_a_g field (see the _O_u_t_p_u_t _M_o_d_e_s sec-
  256.      tion).  The implementation may provide a buffering mechanism; as such,
  257.      when a call to write() completes, all of the bytes written have been
  258.      scheduled for transmission to the device, but the transmission will not
  259.      necessarily have been completed.
  260.  
  261.    SSppeecciiaall CChhaarraacctteerrss
  262.      Certain characters have special functions on input or output or both.
  263.  
  264.      These functions are summarized as follows:
  265.  
  266.      INTR    Special character on input and is recognized if the ISIG flag
  267.              (see the _L_o_c_a_l _M_o_d_e_s section) is enabled.  Generates a SIGINT
  268.              signal which is sent to all processes in the foreground process
  269.              group for which the terminal is the controlling terminal.  If
  270.              ISIG is set, the INTR character is discarded when processed.
  271.  
  272.      QUIT    Special character on input and is recognized if the ISIG flag is
  273.              enabled.  Generates a SIGQUIT signal which is sent to all pro-
  274.              cesses in the foreground process group for which the terminal is
  275.              the controlling terminal.  If ISIG is set, the QUIT character is
  276.              discarded when processed.
  277.  
  278.      ERASE   Special character on input and is recognized if the ICANON flag
  279.              is set.  Erases the last character in the current line; see
  280.              _C_a_n_o_n_i_c_a_l _M_o_d_e _I_n_p_u_t _P_r_o_c_e_s_s_i_n_g. It does not erase beyond the
  281.              start of a line, as delimited by an NL, EOF, or EOL character.
  282.              If ICANON is set, the ERASE character is discarded when pro-
  283.              cessed.
  284.  
  285.      KILL    Special character on input and is recognized if the ICANON flag
  286.              is set.  Deletes the entire line, as delimited by a NL, EOF, or
  287.              EOL character.  If ICANON is set, the KILL character is discarded
  288.              when processed.
  289.  
  290.      EOF     Special character on input and is recognized if the ICANON flag
  291.              is set.  When received, all the bytes waiting to be read are im-
  292.              mediately passed to the process, without waiting for a newline,
  293.              and the EOF is discarded.  Thus, if there are no bytes waiting
  294.              (that is, the EOF occurred at the beginning of a line), a byte
  295.              count of zero is returned from the read(), representing an end-
  296.              of-file indication.  If ICANON is set, the EOF character is dis-
  297.              carded when processed.  NL Special character on input and is rec-
  298.              ognized if the ICANON flag is set.  It is the line delimiter
  299.              `\n'.
  300.  
  301.      EOL     Special character on input and is recognized if the ICANON flag
  302.              is set.  Is an additional line delimiter, like NL.
  303.  
  304.      SUSP    If the ISIG flag is enabled, receipt of the SUSP character causes
  305.              a SIGTSTP signal to be sent to all processes in the foreground
  306.              process group for which the terminal is the controlling terminal,
  307.              and the SUSP character is discarded when processed.
  308.  
  309.      STOP    Special character on both input and output and is recognized if
  310.              the IXON (output control) or IXOFF (input control) flag is set.
  311.              Can be used to temporarily suspend output.  It is useful with
  312.              fast terminals to prevent output from disappearing before it can
  313.              be read.  If IXON is set, the STOP character is discarded when
  314.              processed.
  315.  
  316.      START   Special character on both input and output and is recognized if
  317.              the IXON (output control) or IXOFF (input control) flag is set.
  318.              Can be used to resume output that has been suspended by a STOP
  319.              character.  If IXON is set, the START character is discarded when
  320.              processed.  CR Special character on input and is recognized if
  321.              the ICANON flag is set; it is the `\r', as denoted in the C Stan-
  322.              dard {2}.  When ICANON and ICRNL are set and IGNCR is not set,
  323.              this character is translated into a NL, and has the same effect
  324.              as a NL character.
  325.  
  326.      The following special characters are extensions defined by this system
  327.      and are not a part of 1003.1 termios.
  328.  
  329.  
  330.      EOL2    Secondary EOL character.  Same function as EOL.
  331.  
  332.      WERASE  Special character on input and is recognized if the ICANON flag
  333.              is set.  Erases the last word in the current line according to
  334.              one of two algorithms.  If the ALTWERASE flag is not set, first
  335.              any preceding whitespace is erased, and then the maximal sequence
  336.              of non-whitespace characters.  If ALTWERASE is set, first any
  337.              preceding whitespace is erased, and then the maximal sequence of
  338.              alphabetic/underscores or non alphabetic/underscores.  As a spe-
  339.              cial case in this second algorithm, the first previous non-
  340.              whitespace character is skipped in determining whether the pre-
  341.              ceding word is a sequence of alphabetic/undercores.  This sounds
  342.              confusing but turns out to be quite practical.
  343.  
  344.      REPRINT
  345.              Special character on input and is recognized if the ICANON flag
  346.              is set.  Causes the current input edit line to be retyped.
  347.  
  348.      DSUSP   Has similar actions to the SUSP character, except that the
  349.              SIGTSTP signal is delivered when one of the processes in the
  350.              foreground process group issues a read() to the controlling ter-
  351.              minal.
  352.  
  353.      LNEXT   Special character on input and is recognized if the IEXTEN flag
  354.              is set.  Receipt of this character causes the next character to
  355.              be taken literally.
  356.  
  357.      DISCARD
  358.              Special character on input and is recognized if the IEXTEN flag
  359.              is set.  Receipt of this character toggles the flushing of termi-
  360.              nal output.
  361.  
  362.      STATUS  Special character on input and is recognized if the ICANON flag
  363.              is set.  Receipt of this character causes a SIGINFO signal to be
  364.              sent to the foreground process group of the terminal.  Also, if
  365.              the NOKERNINFO flag is not set, it causes the kernel to write a
  366.              status message to the terminal that displays the current load av-
  367.              erage, the name of the command in the foreground, its process ID,
  368.              the symbolic wait channel, the number of user and system seconds
  369.              used, the percentage of cpu the process is getting, and the resi-
  370.              dent set size of the process.
  371.  
  372.      The NL and CR characters cannot be changed.  The values for all the re-
  373.      maining characters can be set and are described later in the document un-
  374.      der Special Control Characters.
  375.  
  376.      Special character functions associated with changeable special control
  377.      characters can be disabled individually by setting their value to
  378.      {_POSIX_VDISABLE}; see _S_p_e_c_i_a_l _C_o_n_t_r_o_l _C_h_a_r_a_c_t_e_r_s.
  379.  
  380.      If two or more special characters have the same value, the function per-
  381.      formed when that character is received is undefined.
  382.  
  383.    MMooddeemm DDiissccoonnnneecctt
  384.      If a modem disconnect is detected by the terminal interface for a con-
  385.      trolling terminal, and if CLOCAL is not set in the _c___c_f_l_a_g field for the
  386.      terminal, the SIGHUP signal is sent to the controlling process associated
  387.      with the terminal.  Unless other arrangements have been made, this causes
  388.      the controlling process to terminate.  Any subsequent call to the read()
  389.      function returns the value zero, indicating end of file.  Thus, processes
  390.      that read a terminal file and test for end-of-file can terminate appro-
  391.      priately after a disconnect.  Any subsequent write() to the terminal de-
  392.      vice returns -1, with _e_r_r_n_o set to EIO, until the device is closed.
  393.  
  394. GGeenneerraall TTeerrmmiinnaall IInntteerrffaaccee
  395.  
  396.  
  397.    CClloossiinngg aa TTeerrmmiinnaall DDeevviiccee FFiillee
  398.      The last process to close a terminal device file causes any output to be
  399.      sent to the device and any input to be discarded.  Then, if HUPCL is set
  400.      in the control modes, and the communications port supports a disconnect
  401.      function, the terminal device performs a disconnect.
  402.  
  403.    PPaarraammeetteerrss TThhaatt CCaann BBee SSeett
  404.      Routines that need to control certain terminal I/O characteristics do so
  405.      by using the termios structure as defined in the header <_t_e_r_m_i_o_s_._h>. This
  406.      structure contains minimally four scalar elements of bit flags and one
  407.      array of special characters.  The scalar flag elements are named:
  408.      _c___i_f_l_a_g, _c___o_f_l_a_g, _c___c_f_l_a_g, and _c___l_f_l_a_g. The character array is named
  409.      _c___c_c, and its maximum index is NCCS.
  410.  
  411.    IInnppuutt MMooddeess
  412.      Values of the _c___i_f_l_a_g field describe the basic terminal input control,
  413.      and are composed of following masks:
  414.  
  415.            IGNBRK   /* ignore BREAK condition */
  416.            BRKINT   /* map BREAK to SIGINTR */
  417.            IGNPAR   /* ignore (discard) parity errors */
  418.            PARMRK   /* mark parity and framing errors */
  419.            INPCK    /* enable checking of parity errors */
  420.            ISTRIP   /* strip 8th bit off chars */
  421.            INLCR    /* map NL into CR */
  422.            IGNCR    /* ignore CR */
  423.            ICRNL    /* map CR to NL (ala CRMOD) */
  424.            IXON     /* enable output flow control */
  425.            IXOFF    /* enable input flow control */
  426.            IXANY    /* any char will restart after stop */
  427.            IMAXBEL  /* ring bell on input queue full */
  428.  
  429.      In the context of asynchronous serial data transmission, a break condi-
  430.      tion is defined as a sequence of zero-valued bits that continues for more
  431.      than the time to send one byte.  The entire sequence of zero-valued bits
  432.      is interpreted as a single break condition, even if it continues for a
  433.      time equivalent to more than one byte.  In contexts other than asyn-
  434.      chronous serial data transmission the definition of a break condition is
  435.      implementation defined.
  436.  
  437.      If IGNBRK is set, a break condition detected on input is ignored, that
  438.      is, not put on the input queue and therefore not read by any process.  If
  439.      IGNBRK is not set and BRKINT is set, the break condition flushes the in-
  440.      put and output queues and if the terminal is the controlling terminal of
  441.      a foreground process group, the break condition generates a single SIGINT
  442.      signal to that foreground process group.  If neither IGNBRK nor BRKINT is
  443.      set, a break condition is read as a single `\0', or if PARMRK is set, as
  444.      `\377', `\0', `\0'.
  445.  
  446.      If IGNPAR is set, a byte with a framing or parity error (other than
  447.      break) is ignored.
  448.  
  449.      If PARMRK is set, and IGNPAR is not set, a byte with a framing or parity
  450.      error (other than break) is given to the application as the three-charac-
  451.      ter sequence `\377', `\0', X, where `\377', `\0' is a two-character flag
  452.      preceding each sequence and X is the data of the character received in
  453.      error.  To avoid ambiguity in this case, if ISTRIP is not set, a valid
  454.      character of `\377' is given to the application as `\377', `\377'. If
  455.      neither PARMRK nor IGNPAR is set, a framing or parity error (other than
  456.      break) is given to the application as a single character `\0'.
  457.  
  458.      If INPCK is set, input parity checking is enabled.  If INPCK is not set,
  459.      input parity checking is disabled, allowing output parity generation
  460.      without input parity errors.  Note that whether input parity checking is
  461.      enabled or disabled is independent of whether parity detection is enabled
  462.      or disabled (see _C_o_n_t_r_o_l _M_o_d_e_s). If parity detection is enabled but input
  463.      parity checking is disabled, the hardware to which the terminal is con-
  464.      nected recognizes the parity bit, but the terminal special file does not
  465.      check whether this bit is set correctly or not.
  466.  
  467.      If ISTRIP is set, valid input bytes are first stripped to seven bits,
  468.      otherwise all eight bits are processed.
  469.  
  470.      If INLCR is set, a received NL character is translated into a CR charac-
  471.      ter.  If IGNCR is set, a received CR character is ignored (not read).  If
  472.      IGNCR is not set and ICRNL is set, a received CR character is translated
  473.      into a NL character.
  474.  
  475.      If IXON is set, start/stop output control is enabled.  A received STOP
  476.      character suspends output and a received START character restarts output.
  477.      If IXANY is also set, then any character may restart output. When IXON is
  478.      set, START and STOP characters are not read, but merely perform flow con-
  479.      trol functions.  When IXON is not set, the START and STOP characters are
  480.      read.
  481.  
  482.      If IXOFF is set, start/stop input control is enabled.  The system shall
  483.      transmit one or more STOP characters, which are intended to cause the
  484.      terminal device to stop transmitting data, as needed to prevent the input
  485.      queue from overflowing and causing the undefined behavior described in
  486.      _I_n_p_u_t _P_r_o_c_e_s_s_i_n_g _a_n_d _R_e_a_d_i_n_g _D_a_t_a, and shall transmit one or more START
  487.      characters, which are intended to cause the terminal device to resume
  488.      transmitting data, as soon as the device can continue transmitting data
  489.      without risk of overflowing the input queue.  The precise conditions un-
  490.      der which STOP and START characters are transmitted are implementation
  491.      defined.
  492.  
  493.      If IMAXBEL is set and the input queue is full, subsequent input shall
  494.      cause an ASCII BEL character to be transmitted to the the output queue.
  495.  
  496.      The initial input control value after open() is implementation defined.
  497.  
  498.    OOuuttppuutt MMooddeess
  499.      Values of the _c___o_f_l_a_g field describe the basic terminal output control,
  500.      and are composed of the following masks:
  501.  
  502.            OPOST   /* enable following output processing */
  503.            ONLCR   /* map NL to CR-NL (ala CRMOD) */
  504.            OXTABS  /* expand tabs to spaces */
  505.            ONOEOT  /* discard EOT's `^D' on output) */
  506.  
  507.      If OPOST is set, the remaining flag masks are interpreted as follows;
  508.      otherwise characters are transmitted without change.
  509.  
  510.      If ONLCR is set, newlines are translated to carriage return, linefeeds.
  511.  
  512.      If OXTABS is set, tabs are expanded to the appropriate number of spaces
  513.      (assuming 8 column tab stops).
  514.  
  515.      If ONOEOT is set, ASCII EOT NS 's are discarded on output.
  516.  
  517.    CCoonnttrrooll MMooddeess
  518.      Values of the _c___c_f_l_a_g field describe the basic terminal hardware control,
  519.      and are composed of the following masks.  Not all values specified are
  520.      supported by all hardware.
  521.  
  522.            CSIZE       /* character size mask */
  523.            CS5         /* 5 bits (pseudo) */
  524.            CS6         /* 6 bits */
  525.            CS7         /* 7 bits */
  526.  
  527.  
  528.            CS8         /* 8 bits */
  529.            CSTOPB      /* send 2 stop bits */
  530.            CREAD       /* enable receiver */
  531.            PARENB      /* parity enable */
  532.            PARODD      /* odd parity, else even */
  533.            HUPCL       /* hang up on last close */
  534.            CLOCAL      /* ignore modem status lines */
  535.            CCTS_OFLOW  /* CTS flow control of output */
  536.            CRTSCTS     /* same as CCTS_OFLOW */
  537.            CRTS_IFLOW  /* RTS flow control of input */
  538.            MDMBUF      /* flow control output via Carrier */
  539.  
  540.      The CSIZE bits specify the byte size in bits for both transmission and
  541.      reception.  The _c___c_f_l_a_g is masked with CSIZE and compared with the values
  542.      CS5, CS6, CS7, or CS8. This size does not include the parity bit, if any.
  543.      If CSTOPB is set, two stop bits are used, otherwise one stop bit.  For
  544.      example, at 110 baud, two stop bits are normally used.
  545.  
  546.      If CREAD is set, the receiver is enabled.  Otherwise, no character is re-
  547.      ceived.  Not all hardware supports this bit.  In fact, this flag is pret-
  548.      ty silly and if it were not part of the tteerrmmiiooss specification it would be
  549.      omitted.
  550.  
  551.      If PARENB is set, parity generation and detection are enabled and a pari-
  552.      ty bit is added to each character.  If parity is enabled, PARODD speci-
  553.      fies odd parity if set, otherwise even parity is used.
  554.  
  555.      If HUPCL is set, the modem control lines for the port are lowered when
  556.      the last process with the port open closes the port or the process termi-
  557.      nates.  The modem connection is broken.
  558.  
  559.      If CLOCAL is set, a connection does not depend on the state of the modem
  560.      status lines.  If CLOCAL is clear, the modem status lines are monitored.
  561.  
  562.      Under normal circumstances, a call to the open() function waits for the
  563.      modem connection to complete.  However, if the O_NONBLOCK flag is set or
  564.      if CLOCAL has been set, the open() function returns immediately without
  565.      waiting for the connection.
  566.  
  567.      The CCTS_OFLOW (CRTSCTS) flag is currently unused.
  568.  
  569.      If MDMBUF is set then output flow control is controlled by the state of
  570.      Carrier Detect.
  571.  
  572.      If the object for which the control modes are set is not an asynchronous
  573.      serial connection, some of the modes may be ignored; for example, if an
  574.      attempt is made to set the baud rate on a network connection to a termi-
  575.      nal on another host, the baud rate may or may not be set on the connec-
  576.      tion between that terminal and the machine it is directly connected to.
  577.  
  578.    LLooccaall MMooddeess
  579.      Values of the _c___l_f_l_a_g field describe the control of various functions,
  580.      and are composed of the following masks.
  581.  
  582.            ECHOKE      /* visual erase for line kill */
  583.            ECHOE       /* visually erase chars */
  584.            ECHO        /* enable echoing */
  585.            ECHONL      /* echo NL even if ECHO is off */
  586.            ECHOPRT     /* visual erase mode for hardcopy */
  587.            ECHOCTL     /* echo control chars as ^(Char) */
  588.            ISIG        /* enable signals INTR, QUIT, [D]SUSP */
  589.            ICANON      /* canonicalize input lines */
  590.            ALTWERASE   /* use alternate WERASE algorithm */
  591.            IEXTEN      /* enable DISCARD and LNEXT */
  592.  
  593.  
  594.            EXTPROC     /* external processing */
  595.            TOSTOP      /* stop background jobs from output */
  596.            FLUSHO      /* output being flushed (state) */
  597.            NOKERNINFO  /* no kernel output from VSTATUS */
  598.            PENDIN      /* XXX retype pending input (state) */
  599.            NOFLSH      /* don't flush after interrupt */
  600.  
  601.      If ECHO is set, input characters are echoed back to the terminal.  If
  602.      ECHO is not set, input characters are not echoed.
  603.  
  604.      If ECHOE and ICANON are set, the ERASE character causes the terminal to
  605.      erase the last character in the current line from the display, if possi-
  606.      ble.  If there is no character to erase, an implementation may echo an
  607.      indication that this was the case or do nothing.
  608.  
  609.      If ECHOK and ICANON are set, the KILL character causes the current line
  610.      to be discarded and the system echoes the `\n' character after the KILL
  611.      character.
  612.  
  613.      If ECHOKE and ICANON are set, the KILL character causes the current line
  614.      to be discarded and the system causes the terminal to erase the line from
  615.      the display.
  616.  
  617.      If ECHOPRT and ICANON are set, the system assumes that the display is a
  618.      printing device and prints a backslash and the erased characters when
  619.      processing ERASE characters, followed by a forward slash.
  620.  
  621.      If ECHOCTL is set, the system echoes control characters in a visible
  622.      fashion using a caret followed by the control character.
  623.  
  624.      If ALTWERASE is set, the system uses an alternative algorithm for deter-
  625.      mining what constitutes a word when processing WERASE characters (see
  626.      WERASE).
  627.  
  628.      If ECHONL and ICANON are set, the `\n' character echoes even if ECHO is
  629.      not set.
  630.  
  631.      If ICANON is set, canonical processing is enabled.  This enables the
  632.      erase and kill edit functions, and the assembly of input characters into
  633.      lines delimited by NL, EOF, and EOL, as described in _C_a_n_o_n_i_c_a_l _M_o_d_e _I_n_p_u_t
  634.      _P_r_o_c_e_s_s_i_n_g.
  635.  
  636.      If ICANON is not set, read requests are satisfied directly from the input
  637.      queue.  A read is not satisfied until at least MIN bytes have been re-
  638.      ceived or the timeout value TIME expired between bytes.  The time value
  639.      represents tenths of seconds.  See _N_o_n_c_a_n_o_n_i_c_a_l _M_o_d_e _I_n_p_u_t _P_r_o_c_e_s_s_i_n_g for
  640.      more details.
  641.  
  642.      If ISIG is set, each input character is checked against the special con-
  643.      trol characters INTR, QUIT, and SUSP (job control only).  If an input
  644.      character matches one of these control characters, the function associat-
  645.      ed with that character is performed.  If ISIG is not set, no checking is
  646.      done.  Thus these special input functions are possible only if ISIG is
  647.      set.
  648.  
  649.      If IEXTEN is set, implementation-defined functions are recognized from
  650.      the input data.  How IEXTEN being set interacts with ICANON, ISIG, IXON,
  651.      or IXOFF is implementation defined.  If IEXTEN is not set, then implemen-
  652.      tation-defined functions are not recognized, and the corresponding input
  653.      characters are not processed as described for ICANON, ISIG, IXON, and
  654.      IXOFF.
  655.  
  656.      If NOFLSH is set, the normal flush of the input and output queues associ-
  657.      ated with the INTR, QUIT, and SUSP characters are not be done.
  658.  
  659.  
  660.      If TOSTOP is set, the signal SIGTTOU is sent to the process group of a
  661.      process that tries to write to its controlling terminal if it is not in
  662.      the foreground process group for that terminal.  This signal, by default,
  663.      stops the members of the process group.  Otherwise, the output generated
  664.      by that process is output to the current output stream.  Processes that
  665.      are blocking or ignoring SIGTTOU signals are excepted and allowed to pro-
  666.      duce output and the SIGTTOU signal is not sent.
  667.  
  668.      If NOKERNINFO is set, the kernel does not produce a status message when
  669.      processing STATUS characters (see STATUS).
  670.  
  671.    SSppeecciiaall CCoonnttrrooll CChhaarraacctteerrss
  672.      The special control characters values are defined by the array _c___c_c. This
  673.      table lists the array index, the corresponding special character, and the
  674.      system default value.  For an accurate list of the system defaults, con-
  675.      sult the header file <_t_t_y_d_e_f_a_u_l_t_s_._h>.
  676.  
  677.            _I_n_d_e_x _N_a_m_e    _S_p_e_c_i_a_l _C_h_a_r_a_c_t_e_r    _D_e_f_a_u_l_t _V_a_l_u_e
  678.            VEOF          EOF                  ^D
  679.            VEOL          EOL                  _POSIX_VDISABLE
  680.            VEOL2         EOL2                 _POSIX_VDISABLE
  681.            VERASE        ERASE                ^? `\177'
  682.            VWERASE       WERASE               ^W
  683.            VKILL         KILL                 ^U
  684.            VREPRINT      REPRINT              ^R
  685.            VINTR         INTR                 ^C
  686.            VQUIT         QUIT                 ^\\ `\34'
  687.            VSUSP         SUSP                 ^Z
  688.            VDSUSP        DSUSP                ^Y
  689.            VSTART        START                ^Q
  690.            VSTOP         STOP                 ^S
  691.            VLNEXT        LNEXT                ^V
  692.            VDISCARD      DISCARD              ^O
  693.            VMIN          ---                  1
  694.            VTIME         ---                  0
  695.            VSTATUS       STATUS               ^T
  696.  
  697.      If the value of one of the changeable special control characters (see
  698.      _S_p_e_c_i_a_l _C_h_a_r_a_c_t_e_r_s) is {_POSIX_VDISABLE}, that function is disabled; that
  699.      is, no input data is recognized as the disabled special character.  If
  700.      ICANON is not set, the value of {_POSIX_VDISABLE} has no special meaning
  701.      for the VMIN and VTIME entries of the _c___c_c array.
  702.  
  703.      The initial values of the flags and control characters after open() is
  704.      set according to the values in the header <_s_y_s_/_t_t_y_d_e_f_a_u_l_t_s_._h>.
  705.  
  706. 4th Berkeley Distribution       April 19, 1994                              11
  707.